﻿<phone:PhoneApplicationPage 
    x:Class="ALiteTeam.PackageTracer.View.View.SettingPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=SettingsViewModel}"
    shell:SystemTray.IsVisible="False">
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <!--设定配置好的背景图-->
        <Grid.Background>
            <ImageBrush ImageSource="{Binding BackgroundImage, Source={StaticResource ViewModelLocator}}"/>
        </Grid.Background>
        <!--Pivot Control-->
        <controls:Pivot Name="pivot" Title="风讯快递查询">
            <!--Pivot item one-->
            <controls:PivotItem x:Name="pivotInputItem" Header="全局设置">
                <StackPanel>
                    <Grid>
                        <toolkit:ListPicker Visibility="Collapsed" ItemsSource="{Binding ThemeColor, Converter={StaticResource EnumToIEnumerableConverter}}"
                                            SelectedIndex="{Binding Converter={StaticResource EnumToIntConverter}, Path=ThemeColor,Mode=TwoWay}" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="SelectionChanged">
                                    <GalaSoft_MvvmLight_Command:EventToCommand
                                        Command="{Binding SaveCommand}" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                            <toolkit:ListPicker.Header>
                                <TextBlock Text="主题颜色" FontFamily="Segoe WP" FontWeight="Normal" Foreground="{StaticResource PhoneForegroundBrush}"/>
                            </toolkit:ListPicker.Header>
                            <toolkit:ListPicker.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Border Background="Black"  Width="Auto" Height="35">
                                            <TextBlock Text="{Binding}" Foreground="White"/>
                                        </Border>
                                    </Grid>
                                </DataTemplate>
                            </toolkit:ListPicker.ItemTemplate>
                        </toolkit:ListPicker>
                    </Grid>
                    <ScrollViewer VerticalScrollBarVisibility="Disabled"  HorizontalScrollBarVisibility="Auto" Visibility="Collapsed">
                        <ListBox ItemsSource="{Binding BackgroundImages}" Canvas.ZIndex="1200" MinHeight="80"
                            x:Name="lstPreviews" Margin="0" VerticalAlignment="Bottom">
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <VirtualizingStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Opacity="30"/>
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Border BorderThickness="3" BorderBrush="White" CornerRadius="6" Margin="2" >
                                        <Image Canvas.ZIndex="1200" Width="60" Height="100"
                                    Stretch="Uniform" Source="{Binding}"/>
                                    </Border>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </ScrollViewer>
                    <toolkit:ToggleSwitch FontFamily="Segoe WP" FontWeight="Normal" Header="自动更新" Height="110" HorizontalAlignment="Left" IsChecked="{Binding Path=AllowUpdateViaBackground, Mode=TwoWay}" Margin="10,10,0,0" Name="toggleRefreshSwitch" VerticalAlignment="Top" Width="456" >
                        <toolkit:ToggleSwitch.HeaderTemplate>
                            <DataTemplate>
                                <ContentControl Content="自动更新" Foreground="{StaticResource PhoneForegroundBrush}" />
                            </DataTemplate>
                        </toolkit:ToggleSwitch.HeaderTemplate>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Checked">
                                <GalaSoft_MvvmLight_Command:EventToCommand
                                    Command="{Binding SaveAndSwitchCommand}" 
                                    CommandParameter="{Binding ElementName=toggleRefreshSwitch, Path=IsChecked}"/>
                            </i:EventTrigger>
                            <i:EventTrigger EventName="Unchecked">
                                <GalaSoft_MvvmLight_Command:EventToCommand
                                    Command="{Binding SaveAndSwitchCommand}" 
                                    CommandParameter="{Binding ElementName=toggleRefreshSwitch, Path=IsChecked}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </toolkit:ToggleSwitch>
                    <toolkit:ToggleSwitch FontFamily="Segoe WP" FontWeight="Normal" Header="Toast提示" 
                                          Height="110" HorizontalAlignment="Left" 
                                          IsChecked="{Binding Path=AllowToast, Mode=TwoWay}" Margin="10,10,0,0" 
                                          Name="toggleToastSwitch" VerticalAlignment="Top" Width="456" 
                                          IsEnabled="{Binding ElementName=toggleRefreshSwitch, Path=IsChecked}" >
                        <toolkit:ToggleSwitch.HeaderTemplate>
                            <DataTemplate>
                                <ContentControl Content="Toast提示" Foreground="{StaticResource PhoneForegroundBrush}" />
                            </DataTemplate>
                        </toolkit:ToggleSwitch.HeaderTemplate>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Checked">
                                <GalaSoft_MvvmLight_Command:EventToCommand
                            Command="{Binding SaveCommand}" />
                            </i:EventTrigger>
                            <i:EventTrigger EventName="Unchecked">
                                <GalaSoft_MvvmLight_Command:EventToCommand
                            Command="{Binding SaveCommand}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </toolkit:ToggleSwitch>

                </StackPanel>
            </controls:PivotItem>
            <controls:PivotItem Header="关于" Name="pivotInfoItem">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="流量统计(KB）："/>
                        <TextBlock Text="{Binding Path=StreamingAmount, StringFormat=\{0:F\}}"/>
                    </StackPanel>
                    <ListBox>
                        <ListBoxItem Content=" "/>
                        <ListBoxItem Content=" "/>
                        <ListBoxItem Content="主要功能描述:"/>
                        <ListBoxItem Content="1. 提供近80家国内快递的运单查询功能. "/>
                        <ListBoxItem Content="2. 支持条形码扫描录入快递运单. "/>
                        <ListBoxItem Content="3. 提供近80家国内快递资料查询，包括电话，网址 "/>
                        <ListBoxItem Content="以及简介，并可直接拨打和访问。"/>
                        <ListBoxItem Content="4. 提供摘要和明细两种运单查询方式。"/>
                        <ListBoxItem Content="5. 允许后台更新运单状态，并支持设置更新时间间"/>
                        <ListBoxItem Content="隔。（需要在配置中也开启自动更新）"/>
                        <ListBoxItem Content="6. 支持Toast消息提示（仅在状态更新后）"/>
                        <ListBoxItem Content="7. 允许把单个订单钉到桌面上，实时显示运单的最"/>
                        <ListBoxItem Content="近动态。"/>
                        <ListBoxItem Content="  "/>
                        <ListBoxItem Content="2.0功能预告"/>
                        <ListBoxItem Content="1. 引入淘宝API，支持监控淘宝帐号上的快递运单。"/>
                        <ListBoxItem Content="2. 更好的UI和界面设计，支持更换主题和背景图。"/>
                        <ListBoxItem Content="  "/>
                        <ListBoxItem Content="作者：X-Killer@ALiteTeam"/>
                        <ListBoxItem Content="图片设计：初见月"/>
                        <ListBoxItem Content="联系方式：ALiteTeam@live.com"/>


                    </ListBox>
                </StackPanel>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <!--Panorama-based applications should not show an ApplicationBar-->

</phone:PhoneApplicationPage>